package cc.sunni.api.controller.files;

import cc.sunni.common.utils.R;
import cc.sunni.pojo.bo.NewAdminBO;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author jl
 * @since 2021/2/21 22:44
 */
@Api(value = "文件上传的Controller", tags = {"文件上传的Controller"})
@RequestMapping("fs")
public interface FileUploaderControllerApi {

    /**
     * 上传单文件
     */
    @PostMapping("/uploadFace")
    R uploadFace(@RequestParam String userId, MultipartFile file) throws Exception;

    /**
     * 上传多个文件
     */
    @PostMapping("/uploadSomeFiles")
    R uploadSomeFiles(@RequestParam String userId, MultipartFile[] files) throws Exception;

    /**
     * 文件上传到mongodb的gridfs中
     */
    @PostMapping("/uploadToGridFS")
    R uploadToGridFS(@RequestBody NewAdminBO newAdminBO) throws Exception;

    /**
     * 从gridfs中读取图片内容
     */
    @GetMapping("/readInGridFS")
    void readInGridFS(String faceId, HttpServletRequest request, HttpServletResponse response) throws Exception;


    /**
     * 从gridfs中读取图片内容，并且返回base64
     */
    @GetMapping("/readFace64InGridFS")
    R readFace64InGridFS(String faceId, HttpServletRequest request, HttpServletResponse response) throws Exception;
}
